package com.edu.demo.controller;

import com.edu.demo.entity.vo.QuartszSosVO;
//import com.edu.demo.music.TtsMusicUtil;
import com.edu.demo.result.Result;
import com.edu.demo.service.IQuartzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "定时任务")
@RestController
@RequestMapping("/quartz")
public class QuartzController {
//    @Autowired
//    private TtsMusicUtil ttsMusicUtil;
    @Autowired
    private IQuartzService quartzService;

//    @ApiOperation(value = "文字转语音播放地址")
//    @GetMapping("/getMusicUrl")
//    public Result getMusicUrl(String message){
//        String url = ttsMusicUtil.syntheticAudio(message);
//        return Result.success(url).msg("音频地址获取成功");
//    }

    //SchedulerUtil 测试
    @ApiOperation(value = "SchedulerUtil测试")
    @GetMapping("/schedulerUtil")
    public Result schedulerUtil() {
        return Result.success().msg("SchedulerUtil测试成功");
    }

    //接口控制任务的开始或停止
    @ApiOperation(value = "定时任务开关")
    @PostMapping("/startOrStop")
    public Result startOrStop(@Valid @RequestBody QuartszSosVO quartszSosVO) throws ClassNotFoundException {
        quartzService.startOrStop(quartszSosVO);

        return Result.success().msg("定时任务开关成功");
    }
}
